import 'package:get/get.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';

import '../../../../utils/xin_he_toast.dart';
import '../../../shopping_car/models/xin_he_goods_model.dart';
import '../../../shopping_car/xin_he_shopping_car/xin_he_shopping_car_logic.dart';
import 'xin_he_sub_category_state.dart';

class XinHeSubCategoryLogic extends GetxController {
  final XinHeSubCategoryState state = XinHeSubCategoryState();

  RefreshController refreshController = RefreshController(initialRefresh: false);
  RxInt selectIndex = 0.obs;
  RxList leftCategoryList = ['热门回购','新鲜水果','生鲜菜品','粮油菜品','日常用品','新鲜水果','生鲜菜品','粮油菜品','日常用品','新鲜水果','生鲜菜品','粮油菜品','日常用品','新鲜水果','生鲜菜品','粮油菜品',].obs;
  RxList rightCategoryList = [].obs;

  RefreshController rightFreshController = RefreshController(initialRefresh: false);

  // RxInt tabIndex = 0.obs;
  // RxList tabsList = [].obs;
  // RxList itemsList = [].obs;
  RxInt  pageIndex = 0.obs;


  @override
  void onInit() {
    // TODO: implement onInit
    super.onInit();
  }


  ///下拉刷新
  void onRefresh() {
    // _requestLeftCategoryData();
  }

  void changeIndex(index, id) {
    selectIndex.value = index;
    // _requestRightCategoryData(id);
    update();
  }

  ///添加商品进购物车
  void addGoodsToCartAction(XinHeGoodsModel model){

    XinHeToast.center('已添加');
    final allLogic = Get.find<XinHeShoppingCarLogic>();
    allLogic.state.allItemsList.add(model);

  }

}
